package com.waiting.rpc;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author bjweitingting
 * @description
 * @date 2018/8/22
 **/
public class RPCProxyClient implements InvocationHandler {

    private Object target;

    public RPCProxyClient(Object object) {
        target = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
       //1.封装通信细节
        //2.方法调用
        method.invoke(target, args);
        //
        return null;
    }

    public static Object getProxy(Object obj) {
        return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), new RPCProxyClient(obj));
    }

}
